<?php
/**
 * @version SVN: $Id: view.raw.php 1161 2010-04-10 00:37:35Z elkuku $
 * @package
 * @subpackage
 * @author     EasyJoomla {@link http://www.easy-joomla.org Easy-Joomla.org}
 * @author     Nikolai Plath {@link http://www.nik-it.de}
 * @author     Created on 09.04.2010
 * @license    GNU/GPL, see JROOT/LICENSE.php
 */

//-- No direct access
defined('_JEXEC') or die('=;)');

jimport( 'joomla.application.component.view');

/**
 * HTML View class for the EasyCreator Component.
 *
 * @package EasyCreator
 * @subpackage Views
 */
class EasyCreatorViewCodeEye extends JView
{
    protected $EasyProject = null;

    /**
     * Standard display method.
     * (non-PHPdoc)
     * @see libraries/joomla/application/component/JView#display($tpl)
     */
    public function display($tpl = null)
    {
        $response = array();

        $ecr_project = JRequest::getCmd('ecr_project');

        $project = EasyProjectHelper::getProject($ecr_project);

        if( ! $project)
        {
            //-- Something went wrong..
            $response['status'] = 0;
            $response['text'] = JText::sprintf('Unable to load the project %s', $ecr_project);
            ecrHTML::easyFormEnd();

            return;
        }

        ecrLoadHelper('projectmatrix');

        $this->matrix = new EasyProjectMatrix($project, 'pcharts');

        $response['status'] = 1;

        $files = array();
        $size = array();
        $lines = array();

        foreach($this->matrix->projectData as $type => $data)
        {
        	$files[] = $data['files'];
        	$size[] = $data['size'];
        	if(isset($data['lines'])) $lines[] = $data['lines'];
        }//foreach

        $response['files'] = implode(',', $files);
        $response['size'] = implode(',', $size);
        $response['lines'] = implode(',', $lines);
        $response['labels'] = implode(',', array_keys($this->matrix->projectData));

        ob_start();
        parent::display();
        $response['table'] = ob_get_contents();
        ob_end_clean();
        $response['text'] = 'Hi U';

        echo json_encode($response);
    }//function

}// class
